package com.marvels.financial.pay.kqpay.util;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import cn.hutool.json.XML;

public class XMLUtil {
	
	private final static String statement = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>";
	private final static String nodeStart = "<MasMessage xmlns=\"http://www.99bill.com/mas_cnp_merchant_interface\">";
	private final static String nodeEnd = "</MasMessage>";
	/**
	 * 转成块钱需要的XML
	 * @param bean
	 * @return
	 */
	public static String beantoXml(Object bean, String version, String baseNode){
		JSONObject base = JSONUtil.createObj();
		base.put("version", version);
		base.put(baseNode, bean);
		String sendXml = XML.toXml(base);
		StringBuffer sb = new StringBuffer();
		sb.append(statement);
		sb.append(nodeStart);
		sb.append(sendXml);
		sb.append(nodeEnd);
		return sb.toString();
	}
}
